package com.ssky.bean.validator.core.rule;

import com.thoughtworks.xstream.XStream;

import java.io.File;
import java.io.InputStream;

/**
 * @Author: ssky
 * @Date: 2021/07/18
 * @Description:
 */
public class ValidatorRulesParser implements IValidatorRulesParser {
    public static final XStream xStream = new XStream();

    static {
        xStream.processAnnotations(new Class[]{ValidatorRules.class, ValidatorRule.class, Field.class, Rule.class, Property.class});
    }

    public ValidatorRules parse(String str) {
        return (ValidatorRules) xStream.fromXML(str);
    }

    public ValidatorRules parse(File file) {
        return (ValidatorRules) xStream.fromXML(file);
    }

    public ValidatorRules parse(InputStream inputStream) {
        return (ValidatorRules) xStream.fromXML(inputStream);
    }
}